
package org.jma.app.ewisdom.entities;

import java.io.Serializable;
import java.util.Vector;


/**
 * FilePart class represents a chunk of a physical file, when a file is uploaded, 
 * it's linked to a Content and is divided in chunks of 256 Kbytes, this class stores the information 
 * of each chunk,{@link FileDescriptor} class  stores an array of all the FilePart of a file as a new version
 * of the File.<br>
 * @author Jesus Mari, jesmari@ono.com
 * @version 1.0
 * @since 1.0
 * @  
 */
public class FilePart implements Cloneable, Serializable {
	Vector locations= new Vector();
	String fd;
	String filePartName;
	String version;
	int size=0;
	
	
	/**
	 * @return the version 
	 */
	public String getVersion() {
		return version;
	}
	/**
	 * @param version the version to set
	 */
	public void setVersion(String version) {
		this.version = version;
	}

	
	/**
	 * @return the size
	 */
	public int getSize() {
		return size;
	}
	/**
	 * @param size the size to set
	 */
	public void setSize(int size) {
		this.size = size;
	}
	/**
	 * 
	 * @param fd owner fileDescriptor
	 */
	public void setFileDescriptor(String fd){
		this.fd=fd;
	}
	/**
	 * 
	 * @return owner FileDescriptor
	 */
	public String getFileDescriptor(){return fd;}
	
	/**
	 * @see FileLocator
	 * @param loc a FileLocator
	 */
	public void addLocator(FileLocator loc){
		locations.add(loc);
	}
	
	/**
	 * @see FileLocator
	 * @param loc a FileLocator
	 */
	public void removeLocator(FileLocator loc){
		locations.remove(loc);
	}
	
	/**
	 * Array of all the FileLocators where we can find a FilePart
	 * @return FileLocator array
	 */
	public Object[] getLocators(){
		return this.locations.toArray();
	}
	/**
	 * @return the filePartName
	 */
	public String getFilePartName() {
		return filePartName;
	}
	/**
	 * @param filePartName the filePartName to set
	 */
	public void setFilePartName(String filePartName) {
		this.filePartName = filePartName;
	}
	
}
